<!--link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl.WWWROOT_BACKEND; ?>/css/form.css"/-->

<div class="widget-box dataTables_wrapper">
<?php $form = $this->beginWidget('GxActiveForm', array(
	'id' => 'static-page-form',
	//'enableAjaxValidation' => true,
  'htmlOptions'=>array('enctype'=>'multipart/form-data', 'class'=>'form-horizontal'),
));
?>
	<fieldset>

	<p class="note">
		<?php echo Yii::t('app', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
	</p>

	<?php echo $form->errorSummary($model); ?>

		<?php if(Yii::app()->controller->module->title['show']) { ?>
		<div class="control-group">
			<?php echo $form->labelEx($model,'title', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php echo $form->textField($model, 'title', array('maxlength' => 128)); ?>
				<?php echo $form->error($model,'title'); ?>
				<script type="text/javascript" language="javascript">
					jQuery(document).ready(function() {
						$('#StaticPage_title').keyup(function(){
							var value = $('#StaticPage_title').val();
							value = value.replace(/[áàảãạăắằẳẵặâấầẩẫậ]/ig, 'a');
							value = value.replace(/[đ]/ig, 'd');
							value = value.replace(/[éèẻẽẹêếềểễệ]/ig, 'e');
							value = value.replace(/[íìỉĩị]/ig, 'i');
							value = value.replace(/[óòỏõọôốồổỗộơớờởỡợ]/ig, 'o');
							value = value.replace(/[úùủũụưứừửữự]/ig, 'u');
							value = value.replace(/[ýỳỷỹỵ]/ig, 'y');
							value = value.replace(/[^A-Za-z0-9\s_-]/ig, '');
							value = value.replace(/\s/ig, '-');
							value = value.toLowerCase();
							$('#StaticPage_alias').val(value);
						});
					});
				</script>
			</div>
		</div><!-- wd-input -->
		<div class="control-group">
			<?php echo $form->labelEx($model,'alias', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php echo $form->textField($model, 'alias', array('maxlength' => 128, 'readonly' => ' ')); ?>
				<?php echo $form->error($model,'alias'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		
		<?php if(Yii::app()->controller->module->showOnIndex['show']) { ?>
		<div class="control-group">
			<?php echo $form->labelEx($model,'show_on_index', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php echo $form->checkBox($model, 'show_on_index'); ?>
				<?php echo $form->error($model,'show_on_index'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		
		<?php if(Yii::app()->controller->module->image['show']) { ?>
		<div class="control-group">
			<?php echo $form->labelEx($model,'image', array('class'=>'control-label')); ?>
			<div class="controls">
				<div class="image-form">
				<?php if (isset($model->image) && ($model->image != 'NULL')): ?>
					<?php if(file_exists(Yii::app()->createUrl('/').'wwwroot/upload_files/static_pages/' . $model->image)): ?>
						<img src="<?php echo  Yii::app()->createUrl('/').'/wwwroot/upload_files/static_pages/' . $model->image; ?>" width="100" height="70"/>
					<?php else : ?>
						<?php echo CHtml::image('/wwwroot/upload_files/static_pages/no-image.png', 'Image', array(
									'width'		=>	'100',
									'height'	=>	'70'
						)); ?>
					<?php endif ?>
					<div class="clr"></div>
				<?php endif ?>
				<?php echo $form->fileField($model,'image'); ?>
				</div>
				<?php echo $form->error($model,'image'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		
		<?php if(Yii::app()->controller->module->description['show']) { ?>
		<div class="control-group">
		<?php echo $form->labelEx($model,'description', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php //echo $form->textArea($model, 'description'); ?>
				<div class="ckeditor">
				<?php $this->widget('application.extensions.ckeditor.CKEditor', array(
					'model'=>$model,
					'attribute'=>'description',
					'language'=>'en',
					'editorTemplate'=>'advanced',
					'width'	=>	'620px',
					'height'	=>	'420px',
					'options'=>array(
						'filebrowserUploadUrl'=>$this->createUrl('upload'),
					),
					//'rows'=>10, 
					//'cols'=>30,
					'toolbar'=>array(
						array('Bold', 'Italic', 'Underline', 'Strike'),
						array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'),
						array('Format'),
						array( 'Font', 'FontSize', 'FontColor', 'TextColor'),
						'/',
						array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord' ),
						array('Image', 'Table', 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'),
						array('Subscript','Superscript'),
						array( 'Link', 'Unlink' ),
						array('Source'),
					)
					)); 
				?>
				</div>
				<?php echo $form->error($model,'description'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		
		<?php if(Yii::app()->controller->module->content['show']) { ?>
		<div class="control-group">
			<?php echo $form->labelEx($model,'content', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php //echo $form->textArea($model, 'content'); ?>
				<div class="ckeditor">
				<?php $this->widget('application.extensions.ckeditor.CKEditor', array(
					'model'=>$model,
					'attribute'=>'content',
					'language'=>'en',
					'editorTemplate'=>'advanced',
					'width'	=>	'620px',
					'height'	=>	'420px',
					'options'=>array(
						'filebrowserUploadUrl'=>$this->createUrl('upload'),
					),
					//'rows'=>10, 
					//'cols'=>30,
					'toolbar'=>array(
						array('Bold', 'Italic', 'Underline', 'Strike'),
						array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'),
						array('Format'),
						array( 'Font', 'FontSize', 'FontColor', 'TextColor'),
						'/',
						array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord' ),
						array('Image', 'Table', 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'),
						array('Subscript','Superscript'),
						array( 'Link', 'Unlink' ),
						array('Source'),
					)
					)); 
				?>
				</div>
				<?php echo $form->error($model,'content'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		
		<?php if(Yii::app()->controller->module->priority['show']) { ?>
		<div class="control-group">
			<?php echo $form->labelEx($model,'priority', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php echo $form->textField($model, 'priority'); ?>
				<?php echo $form->error($model,'priority'); ?>
			</div>
		</div><!-- wd-input -->
		<?php } ?>
		<!--div class="wd-input">
		< ?php echo $form->labelEx($model,'created'); ?>
		< ?php echo $form->textField($model, 'created'); ?>
		< ?php echo $form->error($model,'created'); ?>
		</div><!-- wd-input -->
		<!--div class="wd-input">
		< ?php echo $form->labelEx($model,'modified'); ?>
		< ?php echo $form->textField($model, 'modified'); ?>
		< ?php echo $form->error($model,'modified'); ?>
		</div><!-- wd-input -->
		<div class="control-group">
			<?php echo $form->labelEx($model,'is_published', array('class'=>'control-label')); ?>
			<div class="controls">
				<?php echo $form->checkBox($model, 'is_published'); ?>
				<?php echo $form->error($model,'is_published'); ?>
			</div>
		</div><!-- wd-input -->
		<div class="form-actions">
		<?php echo GxHtml::submitButton(Yii::t('app', 'Save'), array('class'=>'btn btn-primary')); ?>
		</div>
	</fieldset>

<?php
$this->endWidget();
?>
</div><!-- form -->